import store from "@/store";

export function getAdminId() {
    return store.getters.user.id || ''
}

export function getAdminName() {
    return store.getters.user.nickname || ''
}

const ADMIN_TOKEN = "ADMIN_TOKEN"

export function setAdminToken(adminToken) {
    sessionStorage.setItem(ADMIN_TOKEN, adminToken);
}

export function getAdminToken() {
    return sessionStorage.getItem(ADMIN_TOKEN) || ''
}

export function removeAdminToken() {
    sessionStorage.removeItem(ADMIN_TOKEN)
}


export function getRouterList() {
    return store.getters.user.routeList || []
}

export function getPermissions() {
    return store.getters.user.permissions || []
}

export function getRoleList(){
    return store.getters.user.roles || []
}

export function hasPermission(permission){
    return getPermissions().includes(permission)
}

export function hasRole(role){
    return getRoleList().includes(role)
}

